package com.bezdelnick.forum.web.panel;

import com.bezdelnick.forum.web.component.LinkWithText;
import com.bezdelnick.forum.web.page.AddQuestionPage;
import com.bezdelnick.forum.web.page.IndexPage;
import com.bezdelnick.forum.web.page.LoginPage;
import com.bezdelnick.forum.web.page.UserRegistrationPage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: User
 * Date: 10.08.12
 * Time: 16:16
 * To change this template use File | Settings | File Templates.
 */
public class UserMainMenuPanel extends Panel {
    public UserMainMenuPanel(String id) {
        super(id);

        BookmarkablePageLink gotoListQuestions = new BookmarkablePageLink("goto_list_questions", IndexPage.class);
        gotoListQuestions.setBody(new Model<Serializable>("Go to list answers"));

        BookmarkablePageLink gotoAddQuestion = new BookmarkablePageLink("goto_add_question", AddQuestionPage.class);
        gotoAddQuestion.setBody(new Model<Serializable>("Ask answers"));

        BookmarkablePageLink gotoUserRegistration = new BookmarkablePageLink("goto_registration", UserRegistrationPage.class);
        gotoUserRegistration.setBody(new Model<Serializable>("Registration"));

        LinkWithText gotoLoginPage = new LinkWithText("goto_login_page", "#", "Login"){
            @Override
            public void onClick() {
                super.onClick();
                PageParameters pageParameters = new PageParameters();
                pageParameters.add("userRequest", "ok");
                LoginPage loginPage = new LoginPage(pageParameters);
                redirectToInterceptPage(loginPage);
            }
        };

        LinkWithText gotoLogout = new LinkWithText("goto_logout", "/logout", "Logout");

        add(gotoListQuestions);
        add(gotoAddQuestion);
        add(gotoUserRegistration);
        add(gotoLoginPage);
        add(gotoLogout);
    }
}
